from rest_framework import serializers

from six_it.models import Enterprise, Recruit


class EnterpriseSerializer(serializers.ModelSerializer):
    '''企业序列化器类'''

    class Meta:
        model = Enterprise
        fields = ('id', 'name', 'labels', 'logo', 'recruits', 'summary')


class RecruitSerializer(serializers.ModelSerializer):
    '''企业和职位关联序列化器类'''

    enterprise = EnterpriseSerializer(read_only=True)

    class Meta:
        model = Recruit
        fields = ["id", "jobname", "salary", "condition", "education", "type", "city", "createtime", "enterprise",
                  "labels"]
